package com.linftech.demo.repository;

import com.linftech.demo.document.OrderBom;
import com.mongodb.WriteResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

/**
 * Created by cofey on 2017/3/5.
 */
@Slf4j
@Repository
public class OrderBomRepository extends AbstractBaseRepository<OrderBom> {

    public void removeByDocNo(String entCode, String docNo, Integer recordVersion) {
        Query query = new Query(Criteria.where("entCode").is(entCode).
                and("docNo").is(docNo).
                and("recordStatus").is(1).
                and("recordVersion").is(recordVersion));
        WriteResult writeResult = mongoTemplate.remove(query, OrderBom.collectionName);
        log.info("writeResult:{}", writeResult);
        log.info("n:{}",writeResult.getN());
        log.info("upsertedId:{}",writeResult.getUpsertedId());
        log.info("isUpdateOfExisting:{}",writeResult.isUpdateOfExisting());
    }
}
